<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>4 C | Glossary</title>
<meta name="author" content="psyTeachR Team">
<meta name="description" content="4.1 cache Storing information for later retrieval, usually to save time. In R Markdown documents, you can cache time-consuming code chunks, such as running a complex mixed effects model, by adding...">
<meta name="generator" content="bookdown 0.24 with bs4_book()">
<meta property="og:title" content="4 C | Glossary">
<meta property="og:type" content="book">
<meta property="og:url" content="https://psyteachr.github.io/glossary/c.html">
<meta property="og:image" content="https://psyteachr.github.io/glossary/images/logos/logo.png">
<meta property="og:description" content="4.1 cache Storing information for later retrieval, usually to save time. In R Markdown documents, you can cache time-consuming code chunks, such as running a complex mixed effects model, by adding...">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="4 C | Glossary">
<meta name="twitter:description" content="4.1 cache Storing information for later retrieval, usually to save time. In R Markdown documents, you can cache time-consuming code chunks, such as running a complex mixed effects model, by adding...">
<meta name="twitter:image" content="https://psyteachr.github.io/glossary/images/logos/logo.png">
<!-- JS --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.js" integrity="sha512-zv6Ywkjyktsohkbp9bb45V6tEMoWhzFzXis+LrMehmJZZSys19Yxf1dopHx7WzIKxr5tK2dVcYmaCk2uqdjF4A==" crossorigin="anonymous"></script><script src="https://kit.fontawesome.com/6ecbd6c532.js" crossorigin="anonymous"></script><script src="libs/header-attrs-2.11/header-attrs.js"></script><script src="libs/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="libs/bootstrap-4.6.0/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap-4.6.0/bootstrap.bundle.min.js"></script><script src="libs/bs3compat-0.3.1/transition.js"></script><script src="libs/bs3compat-0.3.1/tabs.js"></script><script src="libs/bs3compat-0.3.1/bs3compat.js"></script><link href="libs/bs4_book-1.0.0/bs4_book.css" rel="stylesheet">
<script src="libs/bs4_book-1.0.0/bs4_book.js"></script><script src="libs/kePrint-0.0.1/kePrint.js"></script><link href="libs/lightable-0.0.1/lightable.css" rel="stylesheet">
<!-- Global site tag (gtag.js) - Google Analytics --><script async src="https://www.googletagmanager.com/gtag/js?id=G-6NP3MF25W3"></script><script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-6NP3MF25W3');
    </script><script src="https://cdnjs.cloudflare.com/ajax/libs/autocomplete.js/0.38.0/autocomplete.jquery.min.js" integrity="sha512-GU9ayf+66Xx2TmpxqJpliWbT5PiGYxpaG8rfnBEk1LL8l1KGkRShhngwdXK1UgqhAzWpZHSiYPc09/NwDQIGyg==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.min.js" integrity="sha512-5CYOlHXGh6QpOFA/TeTylKLWfB3ftPsde7AnmhuitiTX4K5SqCLBeKro6sPS8ilsz1Q4NRx3v8Ko2IBiszzdww==" crossorigin="anonymous"></script><!-- CSS --><link rel="stylesheet" href="include/psyteachr.css">
<link rel="stylesheet" href="include/webex.css">
<link rel="stylesheet" href="include/style.css">
</head>
<body data-spy="scroll" data-target="#toc">

<div class="container-fluid">
<div class="row">
  <header class="col-sm-12 col-lg-3 sidebar sidebar-book"><a class="sr-only sr-only-focusable" href="#content">Skip to main content</a>

    <div class="d-flex align-items-start justify-content-between">
      <h1>
        <a href="index.html" title="">Glossary</a>
      </h1>
      <button class="btn btn-outline-primary d-lg-none ml-2 mt-1" type="button" data-toggle="collapse" data-target="#main-nav" aria-expanded="true" aria-controls="main-nav"><i class="fas fa-bars"></i><span class="sr-only">Show table of contents</span></button>
    </div>

    <div id="main-nav" class="collapse-lg">
      <form role="search">
        <input id="search" class="form-control" type="search" placeholder="Search" aria-label="Search">
</form>

      <nav aria-label="Table of contents"><h2>Table of contents</h2>
        <ul class="book-toc list-unstyled">
<li><a class="" href="index.html">Overview</a></li>
<li><a class="" href="symbols.html"><span class="header-section-number">1</span> Symbols</a></li>
<li><a class="" href="a.html"><span class="header-section-number">2</span> A</a></li>
<li><a class="" href="b.html"><span class="header-section-number">3</span> B</a></li>
<li><a class="active" href="c.html"><span class="header-section-number">4</span> C</a></li>
<li><a class="" href="d.html"><span class="header-section-number">5</span> D</a></li>
<li><a class="" href="e.html"><span class="header-section-number">6</span> E</a></li>
<li><a class="" href="f.html"><span class="header-section-number">7</span> F</a></li>
<li><a class="" href="g.html"><span class="header-section-number">8</span> G</a></li>
<li><a class="" href="h.html"><span class="header-section-number">9</span> H</a></li>
<li><a class="" href="i.html"><span class="header-section-number">10</span> I</a></li>
<li><a class="" href="j.html"><span class="header-section-number">11</span> J</a></li>
<li><a class="" href="k.html"><span class="header-section-number">12</span> K</a></li>
<li><a class="" href="l.html"><span class="header-section-number">13</span> L</a></li>
<li><a class="" href="m.html"><span class="header-section-number">14</span> M</a></li>
<li><a class="" href="n.html"><span class="header-section-number">15</span> N</a></li>
<li><a class="" href="o.html"><span class="header-section-number">16</span> O</a></li>
<li><a class="" href="p.html"><span class="header-section-number">17</span> P</a></li>
<li><a class="" href="q.html"><span class="header-section-number">18</span> Q</a></li>
<li><a class="" href="r.html"><span class="header-section-number">19</span> R</a></li>
<li><a class="" href="s.html"><span class="header-section-number">20</span> S</a></li>
<li><a class="" href="t.html"><span class="header-section-number">21</span> T</a></li>
<li><a class="" href="u.html"><span class="header-section-number">22</span> U</a></li>
<li><a class="" href="v.html"><span class="header-section-number">23</span> V</a></li>
<li><a class="" href="w.html"><span class="header-section-number">24</span> W</a></li>
<li><a class="" href="x.html"><span class="header-section-number">25</span> X</a></li>
<li><a class="" href="y.html"><span class="header-section-number">26</span> Y</a></li>
<li><a class="" href="z.html"><span class="header-section-number">27</span> Z</a></li>
</ul>

        <div class="book-extra">
          <p><a id="book-repo" href="https://github.com/psyteachr/glossary">View book source <i class="fab fa-github"></i></a></p>
        </div>
      </nav>
</div>
  </header><main class="col-sm-12 col-md-9 col-lg-7" id="content"><div id="c" class="section level1" number="4">
<h1>
<span class="header-section-number">4</span> C<a class="anchor" aria-label="anchor" href="#c"><i class="fas fa-link"></i></a>
</h1>

<div id="cache" class="section level2" number="4.1">
<h2>
<span class="header-section-number">4.1</span> cache<a class="anchor" aria-label="anchor" href="#cache"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>Storing information for later retrieval, usually to save time.</dfn></p>
<p>In <a href="r.html#r-markdown">R Markdown</a> documents, you can cache time-consuming code chunks, such as running a complex <a href="l.html#linear-mixed-effects-model">mixed effects model</a>, by adding a <a href="c.html#chunk">chunk</a> option <code>cache = TRUE</code>.</p>
<p><a href="https://bookdown.org/yihui/rmarkdown-cookbook/cache.html" target="_blank">R Markdown Cookbook</a></p>
</div>
<div id="cache-web" class="section level2" number="4.2">
<h2>
<span class="header-section-number">4.2</span> cache (web)<a class="anchor" aria-label="anchor" href="#cache-web"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>In a web browser, external files like <a href="c.html#css">CSS</a>, <a href="j.html#javascript">JavaScript</a>, and images are usually cached so that they don't have to be repeatedly downloaded.</dfn></p>
<p>When you are developing <a href="s.html#shiny">Shiny</a> apps, you may find that your styles, scripts, or images don't update, even though you've changed the source files. This is usually because of the cache, and you can fix it by reloading the web browser, or restarting R and rerunning the Shiny app.</p>

</div>
<div id="categorical" class="section level2" number="4.3">
<h2>
<span class="header-section-number">4.3</span> categorical<a class="anchor" aria-label="anchor" href="#categorical"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>Data that can only take certain values, such as types of pet.</dfn></p>
<p>See <a href="d.html#discrete">discrete</a> or <a href="n.html#nominal">nominal</a>.</p>

</div>
<div id="character" class="section level2" number="4.4">
<h2>
<span class="header-section-number">4.4</span> character<a class="anchor" aria-label="anchor" href="#character"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A <a href="d.html#data-type">data type</a> representing <a href="s.html#string">strings</a> of text.</dfn></p>
<p>Examples of character data are:</p>
<div class="sourceCode" id="cb63"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="st">"I am a string of characters"</span>
<span class="co">#&gt; [1] "I am a string of characters"</span>
<span class="fu"><a href="https://rdrr.io/r/base/paste.html">paste</a></span><span class="op">(</span><span class="st">"The answer is "</span>, <span class="fl">6</span><span class="op">+</span><span class="fl">6</span><span class="op">)</span>
<span class="co">#&gt; [1] "The answer is  12"</span>
<span class="fu"><a href="https://rdrr.io/r/base/character.html">as.character</a></span><span class="op">(</span><span class="fl">100</span><span class="op">)</span>
<span class="co">#&gt; [1] "100"</span></code></pre></div>

</div>
<div id="chunk" class="section level2" number="4.5">
<h2>
<span class="header-section-number">4.5</span> chunk<a class="anchor" aria-label="anchor" href="#chunk"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A section of code in an <a href="r.html#r-markdown">R Markdown</a> file</dfn></p>
<p>In an <code>Rmd</code> file, you can include a chunk by surrounding the code as in the example below:</p>
<div class="verbatim">
<p><code>```{r chunk-name}</code></p>
<div class="sourceCode" id="cb64"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">mean_age</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/mean.html">mean</a></span><span class="op">(</span><span class="va">ages</span><span class="op">)</span> <span class="op">%&gt;%</span> <span class="fu"><a href="https://rdrr.io/r/base/Round.html">round</a></span><span class="op">(</span><span class="fl">2</span><span class="op">)</span></code></pre></div>
<code>```</code>
</div>
<p>Also sometimes called a <a href="b.html#block">block</a>.</p>

</div>
<div id="ci" class="section level2" number="4.6">
<h2>
<span class="header-section-number">4.6</span> CI<a class="anchor" aria-label="anchor" href="#ci"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>Confidence interval: A type of interval estimate used to summarise a given statistic or measurement where a proportion of intervals calculated from the sample(s) will contain the true value of the statistic.</dfn></p>
<p>See <a href="c.html#confidence-interval">confidence interval</a></p>

</div>
<div id="coding-scheme" class="section level2" number="4.7">
<h2>
<span class="header-section-number">4.7</span> coding scheme<a class="anchor" aria-label="anchor" href="#coding-scheme"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>How to represent <a href="c.html#categorical">categorical</a> variables with numbers for use in models</dfn></p>
<ul>
<li><a href="e.html#effect-code">effect code</a></li>
<li><a href="e.html#sum-code">sum code</a></li>
<li>
<a href="e.html#treatment-code">treatment code</a> (dummy code)</li>
</ul>
<p><a href="https://debruine.github.io/post/coding-schemes/" target="_blank">Example of different coding schemes for the same data</a></p>
<p><a href="https://debruine.github.io/faux/articles/contrasts.html" target="_blank">Contrast coding in detail</a></p>
<p><a href="https://marissabarlaz.github.io/portfolio/contrastcoding/" target="_blank">Contrast coding in R</a> by Marissa Barlaz</p>

</div>
<div id="coercion" class="section level2" number="4.8">
<h2>
<span class="header-section-number">4.8</span> coercion<a class="anchor" aria-label="anchor" href="#coercion"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>Changing the data type of values in a vector to a single compatible type.</dfn></p>
<p>If you try to combine values with different <a href="d.html#data-type">data types</a> in a <a href="v.html#vector">vector</a>, they get coerced to a common type. <a href="s.html#string">Strings</a> are most dominant and will coerce any other data type into a string. <a href="d.html#double">Doubles</a> are dominant over <a href="i.html#integer">integers</a> and <a href="n.html#numeric">numeric</a> values are dominant over <a href="l.html#logical">logical</a> values.</p>
<div class="sourceCode" id="cb65"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">2L</span>, <span class="cn">T</span>, <span class="cn">F</span><span class="op">)</span>  <span class="co"># integers and logicals become integers</span>
<span class="co">#&gt; [1] 2 1 0</span>
<span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">1.5</span>, <span class="cn">T</span>, <span class="cn">F</span><span class="op">)</span> <span class="co"># doubles and logicals become doubles</span>
<span class="co">#&gt; [1] 1.5 1.0 0.0</span>
<span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">1.5</span>, <span class="fl">2L</span><span class="op">)</span>   <span class="co"># doubles and integers become doubles</span>
<span class="co">#&gt; [1] 1.5 2.0</span>
<span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"A"</span>, <span class="fl">1.5</span>, <span class="fl">1L</span>, <span class="cn">T</span><span class="op">)</span>  <span class="co"># strings and anything become strings</span>
<span class="co">#&gt; [1] "A"    "1.5"  "1"    "TRUE"</span></code></pre></div>

</div>
<div id="comment" class="section level2" number="4.9">
<h2>
<span class="header-section-number">4.9</span> comment<a class="anchor" aria-label="anchor" href="#comment"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>You can annotate <code>.R</code> files or <a href="c.html#chunk">chunks</a> in <a href="r.html#r-markdown">R Markdown</a> files with comments by prefacing each line of the comment with one or more hash symbols (<code>#</code>).</dfn></p>
<div class="sourceCode" id="cb66"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co"># I'm demonstrating comments in this chunk</span>
<span class="co"># This comment will be added to the document outline ----</span></code></pre></div>
<p>Comments get added to the document outline if you put four or more dashes, equal signs, or hashes at the end. This is a great way to keep track of more complicated scripts.</p>

</div>
<div id="commit" class="section level2" number="4.10">
<h2>
<span class="header-section-number">4.10</span> commit<a class="anchor" aria-label="anchor" href="#commit"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>The action of storing a new snapshot of a project's state in the <a href="g.html#git">git</a> history.</dfn></p>

</div>
<div id="compile" class="section level2" number="4.11">
<h2>
<span class="header-section-number">4.11</span> compile<a class="anchor" aria-label="anchor" href="#compile"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>To create another resource, such as an app, from source code.</dfn></p>
<p>Compiling usually refers to taking human-readable code and converting it into code that is more efficient for a computer to run, but that a human can't read.</p>
<p>In the context of <a href="r.html#r-markdown">R Markdown</a> files, <a href="k.html#knit">knit</a>, <a href="r.html#render">render</a> and compile are sometimes used interchangeably.</p>

</div>
<div id="computational-reproducibility" class="section level2" number="4.12">
<h2>
<span class="header-section-number">4.12</span> computational reproducibility<a class="anchor" aria-label="anchor" href="#computational-reproducibility"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>The extent to which the findings of a study can be repeated with the same raw data but analyzed by different researchers or by the same researchers on a different occasion.</dfn></p>
<p>See also <a href="r.html#reproducibility">reproducibility</a>.</p>

</div>
<div id="concatenate" class="section level2" number="4.13">
<h2>
<span class="header-section-number">4.13</span> concatenate<a class="anchor" aria-label="anchor" href="#concatenate"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>To combine strings or vectors.</dfn></p>
<p>When referring to strings, concatenate means to add strings together using the function <code>paste</code> (adds a space between strings) or <code>paste0</code> (doesn't add anything between strings).</p>
<div class="sourceCode" id="cb67"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">subject_name</span> <span class="op">&lt;-</span> <span class="st">"Lisa"</span>
<span class="fu"><a href="https://rdrr.io/r/base/paste.html">paste</a></span><span class="op">(</span><span class="st">"Hello,"</span>, <span class="va">subject_name</span><span class="op">)</span>
<span class="co">#&gt; [1] "Hello, Lisa"</span></code></pre></div>
<p>When referring to other types of variables, concatenate can mean to create a vector with those variables, usually using the <code>c</code> function. For example, you could concatenate the numbers 1, 3, 6, and 10 like this: <code><a href="https://rdrr.io/r/base/c.html">c(1, 3, 6, 10)</a></code>. You can concatenate two <a href="v.html#vector">vectors</a> as well:</p>
<div class="sourceCode" id="cb68"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">v1</span> <span class="op">&lt;-</span> <span class="fl">1</span><span class="op">:</span><span class="fl">5</span>
<span class="va">v2</span> <span class="op">&lt;-</span> <span class="fl">11</span><span class="op">:</span><span class="fl">15</span>
<span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="va">v1</span>, <span class="va">v2</span><span class="op">)</span>
<span class="co">#&gt;  [1]  1  2  3  4  5 11 12 13 14 15</span></code></pre></div>
<div class="warning">
<p>Remember, a <a href="v.html#vector">vector</a> can only have one <a href="d.html#data_type">data type</a>. So if you concatenate a <a href="s.html#string">string</a> vector and a <a href="n.html#numeric">numeric</a> vector, the numbers will get turned into their string versions. If you concatenate an <a href="i.html#integer">integer</a> and a <a href="d.html#double">double</a> vector, the integers will be converted to doubles.</p>
</div>
<div class="sourceCode" id="cb69"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">strings</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"a"</span>, <span class="st">"c"</span>, <span class="st">"e"</span><span class="op">)</span>
<span class="va">integers</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">1L</span>, <span class="fl">3L</span>, <span class="fl">5L</span><span class="op">)</span>
<span class="va">doubles</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">1.1</span>, <span class="fl">3.3</span>, <span class="fl">5.5</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="va">strings</span>, <span class="va">integers</span><span class="op">)</span>
<span class="co">#&gt; [1] "a" "c" "e" "1" "3" "5"</span>
<span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="va">doubles</span>, <span class="va">integers</span><span class="op">)</span>
<span class="co">#&gt; [1] 1.1 3.3 5.5 1.0 3.0 5.0</span></code></pre></div>

</div>
<div id="confidence-interval" class="section level2" number="4.14">
<h2>
<span class="header-section-number">4.14</span> confidence interval<a class="anchor" aria-label="anchor" href="#confidence-interval"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A type of interval estimate used to summarise a given statistic or measurement where a proportion of intervals calculated from the sample(s) will contain the true value of the statistic.</dfn></p>
<p>For example, 95% Confidence Intervals of the mean state that if you were to run the same study on 100 samples and calculate this interval for each iteration of the study, then 95 of the intervals calculated will contain the true mean of the population.</p>
<p>Most commonly cited Confidence Intervals are the 95% Confidence Interval and the 99% Confidence Interval. The 95% CI and 99% CI of the mean are calculated as follows:</p>
<ul>
<li><span class="math inline">\(95\%\ CI = \mu ± 1.96 \times SD\)</span></li>
<li><span class="math inline">\(99\%\ CI = \mu ± 2.58 \times SD\)</span></li>
</ul>
<p>For example, given <span class="math inline">\(\mu\)</span> = 10 and <span class="math inline">\(SD\)</span> = 1.25, the <span class="math inline">\(95\%\ CI = [7.55, 12.45]\)</span></p>
<p>There are a number of misconceptions about Confidence Intervals and it would be worth reading the following papers:</p>
<ul>
<li><p><a href="https://link.springer.com/article/10.1007/s10654-016-0149-3" target="_blank">Greenland, S., Senn, S.J., Rothman, K.J. et al. Statistical tests, P values, confidence intervals, and power: a guide to misinterpretations. Eur J Epidemiol 31, 337–350 (2016). https://doi.org/10.1007/s10654-016-0149-3</a></p></li>
<li><p><a href="https://link.springer.com/article/10.3758%2Fs13423-013-0572-3" target="_blank">Hoekstra, R., Morey, R.D., Rouder, J.N. et al. Robust misinterpretation of confidence intervals. Psychon Bull Rev 21, 1157–1164 (2014). https://doi.org/10.3758/s13423-013-0572-3</a></p></li>
</ul>
</div>
<div id="conflict" class="section level2" number="4.15">
<h2>
<span class="header-section-number">4.15</span> conflict<a class="anchor" aria-label="anchor" href="#conflict"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>Having two <a href="p.html#package">packages</a> loaded that have a <a href="f.html#function">function</a> with the same name.</dfn></p>
<p>For example, when you load the <a href="t.html#tidyverse">tidyverse</a>, you will see several warnings under the Conflicts heading.</p>
<div class="sourceCode" id="cb70"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://tidyverse.tidyverse.org">tidyverse</a></span><span class="op">)</span></code></pre></div>
<p><code>
── Conflicts ───── tidyverse_conflicts() ──<br><span style="color:red;">x</span> <span style="color:rgb(52,101,164);">dplyr</span>::<span style="color:green;">filter()</span> masks <span style="color:rgb(52,101,164);">stats</span>::filter()<br><span style="color:red;">x</span> <span style="color:rgb(52,101,164);">lag()</span>::<span style="color:green;">filter()</span> masks <span style="color:rgb(52,101,164);">stats</span>::lag()
</code></p>
<p>This means that the stats package has functions called <code><a href="https://dplyr.tidyverse.org/reference/filter.html">filter()</a></code> and <code><a href="https://dplyr.tidyverse.org/reference/lead-lag.html">lag()</a></code>, but the dplyr package (part of the tidyverse), also has functions with the same name.</p>
<p>Because you loaded dplyr <em>after</em> stats (which is loaded by default when you start R), the functions from dplyr <a href="m.html#mask">mask</a> the functions from stats, but you can still use the functions from stats, you just need to preface them with <code>stats::</code>.</p>
<p>Sometime, the two functions do totally different things. There just aren't enough names to go around; this is why all packages aren't loaded by default. For example, <code><a href="https://rdrr.io/r/stats/filter.html">stats::filter()</a></code> applies linear filtering to a time series, while <code><a href="https://dplyr.tidyverse.org/reference/filter.html">dplyr::filter()</a></code> subsets a data frame.</p>
<div class="sourceCode" id="cb71"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">stats</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/r/stats/filter.html">filter</a></span><span class="op">(</span><span class="fl">1</span><span class="op">:</span><span class="fl">10</span>, <span class="fu"><a href="https://rdrr.io/r/base/rep.html">rep</a></span><span class="op">(</span><span class="fl">1</span>, <span class="fl">3</span><span class="op">)</span><span class="op">)</span>
<span class="co">#&gt; Time Series:</span>
<span class="co">#&gt; Start = 1 </span>
<span class="co">#&gt; End = 10 </span>
<span class="co">#&gt; Frequency = 1 </span>
<span class="co">#&gt;  [1] NA  6  9 12 15 18 21 24 27 NA</span></code></pre></div>
<div class="sourceCode" id="cb72"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="fu">tidyr</span><span class="fu">::</span><span class="va"><a href="https://tidyr.tidyverse.org/reference/table1.html">table1</a></span>, <span class="va">country</span> <span class="op">==</span> <span class="st">"Afghanistan"</span><span class="op">)</span></code></pre></div>
<div class="kable-table">
<div class="inline-table"><table class="table table-sm">
<thead><tr>
<th style="text-align:left;">
country
</th>
<th style="text-align:right;">
year
</th>
<th style="text-align:right;">
cases
</th>
<th style="text-align:right;">
population
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:left;">
Afghanistan
</td>
<td style="text-align:right;">
1999
</td>
<td style="text-align:right;">
745
</td>
<td style="text-align:right;">
19987071
</td>
</tr>
<tr>
<td style="text-align:left;">
Afghanistan
</td>
<td style="text-align:right;">
2000
</td>
<td style="text-align:right;">
2666
</td>
<td style="text-align:right;">
20595360
</td>
</tr>
</tbody>
</table></div>
</div>
<p>In other cases, a package will name a function the same as a base R function on purpose, in order to do the same thing with more features. For example, <code><a href="https://rdrr.io/r/base/sets.html">base::setdiff()</a></code> and <code><a href="https://generics.r-lib.org/reference/setops.html">dplyr::setdiff()</a></code> both return rows from the first table that are not in the second table, but the base R version requires columns to be in the same order, while the dplyr version does not.</p>
<div class="sourceCode" id="cb73"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co"># define overlapping tables</span>
<span class="va">t1</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>a <span class="op">=</span> <span class="fl">1</span><span class="op">:</span><span class="fl">3</span>, b <span class="op">=</span> <span class="fl">1</span><span class="op">:</span><span class="fl">3</span><span class="op">)</span>
<span class="va">t2</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>b <span class="op">=</span> <span class="fl">2</span><span class="op">:</span><span class="fl">4</span>, a <span class="op">=</span> <span class="fl">2</span><span class="op">:</span><span class="fl">4</span><span class="op">)</span>

<span class="co"># concludes all t1 rows are not in t2</span>
<span class="fu">base</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/r/base/sets.html">setdiff</a></span><span class="op">(</span><span class="va">t1</span>, <span class="va">t2</span><span class="op">)</span></code></pre></div>
<div class="kable-table">
<div class="inline-table"><table class="table table-sm">
<thead><tr>
<th style="text-align:right;">
a
</th>
<th style="text-align:right;">
b
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:right;">
1
</td>
<td style="text-align:right;">
1
</td>
</tr>
<tr>
<td style="text-align:right;">
2
</td>
<td style="text-align:right;">
2
</td>
</tr>
<tr>
<td style="text-align:right;">
3
</td>
<td style="text-align:right;">
3
</td>
</tr>
</tbody>
</table></div>
</div>
<div class="sourceCode" id="cb74"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co"># concludes only 1 t1 row is not in t2</span>
<span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://generics.r-lib.org/reference/setops.html">setdiff</a></span><span class="op">(</span><span class="va">t1</span>, <span class="va">t2</span><span class="op">)</span></code></pre></div>
<div class="kable-table">
<div class="inline-table"><table class="table table-sm">
<thead><tr>
<th style="text-align:right;">
a
</th>
<th style="text-align:right;">
b
</th>
</tr></thead>
<tbody><tr>
<td style="text-align:right;">
1
</td>
<td style="text-align:right;">
1
</td>
</tr></tbody>
</table></div>
</div>

</div>
<div id="console" class="section level2" number="4.16">
<h2>
<span class="header-section-number">4.16</span> console<a class="anchor" aria-label="anchor" href="#console"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>The <a href="p.html#panes">pane</a> in RStudio where you can type in commands and view output messages.</dfn></p>
<p>Commands typed into the console are not saved in a script, although they may be saved in the history.</p>

</div>
<div id="container" class="section level2" number="4.17">
<h2>
<span class="header-section-number">4.17</span> container<a class="anchor" aria-label="anchor" href="#container"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A data structure that aggregates data, such as a <a href="v.html#vector">vector</a>, <a href="l.html#list">list</a>, <a href="m.html#matrix">matrix</a>, or <a href="d.html#data-frame">data frame</a></dfn></p>
<div class="sourceCode" id="cb75"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co"># vector</span>
<span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">1</span>,<span class="fl">2</span>,<span class="fl">3</span>,<span class="fl">4</span><span class="op">)</span> 
<span class="co">#&gt; [1] 1 2 3 4</span>
<span class="co"># list</span>
<span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="fl">1</span>, <span class="st">"A"</span>, <span class="cn">TRUE</span><span class="op">)</span>
<span class="co">#&gt; [[1]]</span>
<span class="co">#&gt; [1] 1</span>
<span class="co">#&gt; </span>
<span class="co">#&gt; [[2]]</span>
<span class="co">#&gt; [1] "A"</span>
<span class="co">#&gt; </span>
<span class="co">#&gt; [[3]]</span>
<span class="co">#&gt; [1] TRUE</span>
<span class="co"># matrix</span>
<span class="fu"><a href="https://rdrr.io/r/base/matrix.html">matrix</a></span><span class="op">(</span><span class="fl">1</span><span class="op">:</span><span class="fl">6</span>, nrow <span class="op">=</span> <span class="fl">2</span><span class="op">)</span>
<span class="co">#&gt;      [,1] [,2] [,3]</span>
<span class="co">#&gt; [1,]    1    3    5</span>
<span class="co">#&gt; [2,]    2    4    6</span>
<span class="co"># data frame</span>
<span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>
  id <span class="op">=</span> <span class="fl">1</span><span class="op">:</span><span class="fl">5</span>,
  name <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Lisa"</span>, <span class="st">"Phil"</span>, <span class="st">"Helena"</span>, <span class="st">"Rachel"</span>, <span class="st">"Jack"</span><span class="op">)</span>
<span class="op">)</span></code></pre></div>
<div class="kable-table">
<div class="inline-table"><table class="table table-sm">
<thead><tr>
<th style="text-align:right;">
id
</th>
<th style="text-align:left;">
name
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:right;">
1
</td>
<td style="text-align:left;">
Lisa
</td>
</tr>
<tr>
<td style="text-align:right;">
2
</td>
<td style="text-align:left;">
Phil
</td>
</tr>
<tr>
<td style="text-align:right;">
3
</td>
<td style="text-align:left;">
Helena
</td>
</tr>
<tr>
<td style="text-align:right;">
4
</td>
<td style="text-align:left;">
Rachel
</td>
</tr>
<tr>
<td style="text-align:right;">
5
</td>
<td style="text-align:left;">
Jack
</td>
</tr>
</tbody>
</table></div>
</div>
<p>A container may also refer to a virtual software environment that can be used to make sure that your code has the intended versions of all packages. <a href="https://www.docker.com/" target="_blank">Docker</a>, <a href="https://mybinder.org/" target="_blank">Binder</a> and <a href="https://codeocean.com/" target="_blank">Code Ocean</a> are popular conatiner types.</p>

</div>
<div id="continuous" class="section level2" number="4.18">
<h2>
<span class="header-section-number">4.18</span> continuous<a class="anchor" aria-label="anchor" href="#continuous"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>Data that can take on any values between other existing values.</dfn></p>
<p>As opposed to <a href="d.html#discrete">discrete</a> data, where fractional values don't make sense, continuous data can take fractional values (as far as the sensitivity of the measurement allows). So even if you are measuring height to the nearest whole centimeter, this is continuous data because it is possible and makes sense for intermediate values to exist.</p>

</div>
<div id="correlation-matrix" class="section level2" number="4.19">
<h2>
<span class="header-section-number">4.19</span> correlation matrix<a class="anchor" aria-label="anchor" href="#correlation-matrix"><i class="fas fa-link"></i></a>
</h2>
<p><dfn><a href="p.html#parameter">Parameters</a> showing how a set of <a href="v.html#vector">vectors</a> are <a href="c.html#correlation">correlated</a>.</dfn></p>
<p>This is set up as a <a href="m.html#matrix">matrix</a> with 1.0 along the diagonal, meaning that every variable is perfectly correlated with itself.</p>
<div class="sourceCode" id="cb76"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">data</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://tibble.tidyverse.org/reference/tibble.html">tibble</a></span><span class="op">(</span>
  A <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/Normal.html">rnorm</a></span><span class="op">(</span><span class="fl">100</span><span class="op">)</span>,
  B <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/Normal.html">rnorm</a></span><span class="op">(</span><span class="fl">100</span><span class="op">)</span>, <span class="co"># uncorrelated with A</span>
  C <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/Normal.html">rnorm</a></span><span class="op">(</span><span class="fl">100</span><span class="op">)</span> <span class="op">+</span> <span class="va">A</span>, <span class="co"># positively correlated with A</span>
  D <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/Normal.html">rnorm</a></span><span class="op">(</span><span class="fl">100</span><span class="op">)</span> <span class="op">-</span> <span class="va">A</span> <span class="co"># negatively correlated with A</span>
<span class="op">)</span>

<span class="fu"><a href="https://rdrr.io/r/stats/cor.html">cor</a></span><span class="op">(</span><span class="va">data</span><span class="op">)</span> <span class="co"># correlation matrix</span>
<span class="co">#&gt;               A             B           C           D</span>
<span class="co">#&gt; A  1.000000e+00 -9.943199e-04  0.66356312 -0.69155202</span>
<span class="co">#&gt; B -9.943199e-04  1.000000e+00 -0.03771143 -0.04160253</span>
<span class="co">#&gt; C  6.635631e-01 -3.771143e-02  1.00000000 -0.39843597</span>
<span class="co">#&gt; D -6.915520e-01 -4.160253e-02 -0.39843597  1.00000000</span></code></pre></div>

</div>
<div id="correlation" class="section level2" number="4.20">
<h2>
<span class="header-section-number">4.20</span> correlation<a class="anchor" aria-label="anchor" href="#correlation"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>The relationship two <a href="v.html#vector">vectors</a> have to each other.</dfn></p>
<p>If you sample two sets of numbers independently, they will have a correlation close to 0 (on average). If one number perfectly predicts the other, the correlation is 1 if one gets bigger as the other gets bigger and -1 if one gets smaller as the other gets smaller.</p>
<div class="figure" style="text-align: center">
<span style="display:block;" id="fig:cor"></span>
<img src="_main_files/figure-html/cor-1.png" alt="Different Correlations (n = 100)" width="100%"><p class="caption">
Figure 4.1: Different Correlations (n = 100)
</p>
</div>

</div>
<div id="covariance-matrix" class="section level2" number="4.21">
<h2>
<span class="header-section-number">4.21</span> covariance matrix<a class="anchor" aria-label="anchor" href="#covariance-matrix"><i class="fas fa-link"></i></a>
</h2>
<p><dfn><a href="p.html#parameter">Parameters</a> showing how a set of <a href="v.html#vector">vectors</a> vary and are <a href="c.html#correlation">correlated</a>.</dfn></p>
<p>The covariance <a href="m.html#matrix">matrix</a> is related to the <a href="c.html#correlation-matrix">correlation matrix</a>, but also incorporates information about the <a href="s.html#standard-deviation">standard deviations</a> of all the variables.</p>
<div class="sourceCode" id="cb77"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">data</span> <span class="op">&lt;-</span> <span class="fu">faux</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/faux/man/rnorm_multi.html">rnorm_multi</a></span><span class="op">(</span>
  n <span class="op">=</span> <span class="fl">100</span>,
  mu <span class="op">=</span> <span class="fl">0</span>,
  sd <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span>A <span class="op">=</span> <span class="fl">1</span>, B <span class="op">=</span> <span class="fl">2</span>, C <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>,
  r <span class="op">=</span> <span class="fl">0.5</span>,
  empirical <span class="op">=</span> <span class="cn">TRUE</span>
<span class="op">)</span>

<span class="fu"><a href="https://rdrr.io/r/stats/cor.html">cor</a></span><span class="op">(</span><span class="va">data</span><span class="op">)</span> <span class="co"># correlation matrix</span>
<span class="co">#&gt;     A   B   C</span>
<span class="co">#&gt; A 1.0 0.5 0.5</span>
<span class="co">#&gt; B 0.5 1.0 0.5</span>
<span class="co">#&gt; C 0.5 0.5 1.0</span>
<span class="fu"><a href="https://rdrr.io/r/stats/cor.html">cov</a></span><span class="op">(</span><span class="va">data</span><span class="op">)</span> <span class="co"># covariance matrix</span>
<span class="co">#&gt;     A B   C</span>
<span class="co">#&gt; A 1.0 1 1.5</span>
<span class="co">#&gt; B 1.0 4 3.0</span>
<span class="co">#&gt; C 1.5 3 9.0</span></code></pre></div>
<p>The matrix of the products of the standard deviations is called "sigma". If you multiply this by the correlation matrix, you get the covariance matrix.</p>
<div class="sourceCode" id="cb78"><pre class="downlit sourceCode r">
<code class="sourceCode R">  <span class="co"># multiply SDs    A    B    C</span>
<span class="va">sigma</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/matrix.html">matrix</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">1</span><span class="op">*</span><span class="fl">1</span>, <span class="fl">1</span><span class="op">*</span><span class="fl">2</span>, <span class="fl">1</span><span class="op">*</span><span class="fl">3</span>,  <span class="co"># A</span>
                  <span class="fl">2</span><span class="op">*</span><span class="fl">1</span>, <span class="fl">2</span><span class="op">*</span><span class="fl">2</span>, <span class="fl">2</span><span class="op">*</span><span class="fl">3</span>,  <span class="co"># B</span>
                  <span class="fl">3</span><span class="op">*</span><span class="fl">1</span>, <span class="fl">3</span><span class="op">*</span><span class="fl">2</span>, <span class="fl">3</span><span class="op">*</span><span class="fl">3</span><span class="op">)</span>, <span class="co"># C</span>
                nrow <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>
<span class="va">sigma</span> <span class="op">*</span> <span class="fu"><a href="https://rdrr.io/r/stats/cor.html">cor</a></span><span class="op">(</span><span class="va">data</span><span class="op">)</span>
<span class="co">#&gt;     A B   C</span>
<span class="co">#&gt; A 1.0 1 1.5</span>
<span class="co">#&gt; B 1.0 4 3.0</span>
<span class="co">#&gt; C 1.5 3 9.0</span></code></pre></div>

</div>
<div id="cran" class="section level2" number="4.22">
<h2>
<span class="header-section-number">4.22</span> CRAN<a class="anchor" aria-label="anchor" href="#cran"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>The Comprehensive R Archive Network: a network of ftp and web servers around the world that store identical, up-to-date, versions of code and documentation for R.</dfn></p>
<p><a href="p.html#package">Packages</a> that you download from CRAN have been checked to make sure they won't harm your computer. You can learn more about CRAN at <a href="https://cran.r-project.org/" target="_blank">https://cran.r-project.org/</a>.</p>

</div>
<div id="cronbachs-alpha" class="section level2" number="4.23">
<h2>
<span class="header-section-number">4.23</span> Cronbach's alpha<a class="anchor" aria-label="anchor" href="#cronbachs-alpha"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>A measure used to assess the internal consistency of scale items</dfn></p>
<p>If a scale is a reliable measure of a concept, then the items of the scale should consistently measure that concept. A scale where all the items perfectly measure the same concept will have a Cronbach's alpha close to 1.0, basically meaning that all the items are nearly perfectly correlated. A scale where each item measures a totally different concept will have a Cronbach's alpha close to 0.0, meaning that each item is uncorrelated with the others.</p>
<div class="warning">
<p>Remember that internal reliability is not the same as external reliability. A scale can have a very high Cronbach's alpha, meaning it measures <em>something</em> well, but that thing may not be what you meant to measure.</p>
</div>
<p>We can use the function <code><a href="https://rdrr.io/pkg/psych/man/alpha.html">psych::alpha()</a></code> to calculate Cronbach's alpha.</p>
<div class="sourceCode" id="cb79"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="co"># read in data from the 3 domains of disgust scale</span>
<span class="va">disgust</span> <span class="op">&lt;-</span> <span class="fu">readr</span><span class="fu">::</span><span class="fu"><a href="https://readr.tidyverse.org/reference/read_delim.html">read_csv</a></span><span class="op">(</span><span class="st">"https://psyteachr.github.io/msc-data-skills/data/disgust.csv"</span><span class="op">)</span>
  
<span class="co"># select just the items that measure pathogen disgust</span>
<span class="va">pathogen_alpha</span> <span class="op">&lt;-</span> <span class="va">disgust</span> <span class="op">%&gt;%</span>
  <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">pathogen1</span><span class="op">:</span><span class="va">pathogen7</span><span class="op">)</span> <span class="op">%&gt;%</span>
  <span class="fu">psych</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/psych/man/alpha.html">alpha</a></span><span class="op">(</span><span class="op">)</span></code></pre></div>
<p>You often just want to report the raw or standard alpha.</p>
<div class="sourceCode" id="cb80"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">pathogen_alpha</span><span class="op">$</span><span class="va">total</span><span class="op">$</span><span class="va">raw_alpha</span>
<span class="co">#&gt; [1] 0.7379495</span>
<span class="va">pathogen_alpha</span><span class="op">$</span><span class="va">total</span><span class="op">$</span><span class="va">std.alpha</span>
<span class="co">#&gt; [1] 0.7441191</span></code></pre></div>
<p>The <code>item.stats</code> section gives you some <a href="d.html#descriptive">descriptive</a> statistics about each item (see <code><a href="https://rdrr.io/pkg/psych/man/alpha.html">?psych::alpha</a></code> for more info).</p>
<div class="sourceCode" id="cb81"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">pathogen_alpha</span><span class="op">$</span><span class="va">item.stats</span></code></pre></div>
<div class="kable-table">
<div class="inline-table"><table class="table table-sm">
<thead><tr>
<th style="text-align:left;">
</th>
<th style="text-align:right;">
n
</th>
<th style="text-align:right;">
raw.r
</th>
<th style="text-align:right;">
std.r
</th>
<th style="text-align:right;">
r.cor
</th>
<th style="text-align:right;">
r.drop
</th>
<th style="text-align:right;">
mean
</th>
<th style="text-align:right;">
sd
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:left;">
pathogen1
</td>
<td style="text-align:right;">
19668
</td>
<td style="text-align:right;">
0.6035673
</td>
<td style="text-align:right;">
0.6264342
</td>
<td style="text-align:right;">
0.5293053
</td>
<td style="text-align:right;">
0.4530070
</td>
<td style="text-align:right;">
4.443156
</td>
<td style="text-align:right;">
1.457303
</td>
</tr>
<tr>
<td style="text-align:left;">
pathogen2
</td>
<td style="text-align:right;">
19683
</td>
<td style="text-align:right;">
0.6371098
</td>
<td style="text-align:right;">
0.6287978
</td>
<td style="text-align:right;">
0.5371302
</td>
<td style="text-align:right;">
0.4610671
</td>
<td style="text-align:right;">
3.254026
</td>
<td style="text-align:right;">
1.745723
</td>
</tr>
<tr>
<td style="text-align:left;">
pathogen3
</td>
<td style="text-align:right;">
19687
</td>
<td style="text-align:right;">
0.6489288
</td>
<td style="text-align:right;">
0.6599706
</td>
<td style="text-align:right;">
0.5842526
</td>
<td style="text-align:right;">
0.4917248
</td>
<td style="text-align:right;">
3.171941
</td>
<td style="text-align:right;">
1.616815
</td>
</tr>
<tr>
<td style="text-align:left;">
pathogen4
</td>
<td style="text-align:right;">
19683
</td>
<td style="text-align:right;">
0.6217909
</td>
<td style="text-align:right;">
0.6168016
</td>
<td style="text-align:right;">
0.5156972
</td>
<td style="text-align:right;">
0.4397615
</td>
<td style="text-align:right;">
3.657573
</td>
<td style="text-align:right;">
1.755883
</td>
</tr>
<tr>
<td style="text-align:left;">
pathogen5
</td>
<td style="text-align:right;">
19678
</td>
<td style="text-align:right;">
0.6384423
</td>
<td style="text-align:right;">
0.6657726
</td>
<td style="text-align:right;">
0.5920388
</td>
<td style="text-align:right;">
0.4997309
</td>
<td style="text-align:right;">
4.282397
</td>
<td style="text-align:right;">
1.435962
</td>
</tr>
<tr>
<td style="text-align:left;">
pathogen6
</td>
<td style="text-align:right;">
19655
</td>
<td style="text-align:right;">
0.6120328
</td>
<td style="text-align:right;">
0.5923052
</td>
<td style="text-align:right;">
0.4785793
</td>
<td style="text-align:right;">
0.4119616
</td>
<td style="text-align:right;">
3.808751
</td>
<td style="text-align:right;">
1.878335
</td>
</tr>
<tr>
<td style="text-align:left;">
pathogen7
</td>
<td style="text-align:right;">
19692
</td>
<td style="text-align:right;">
0.6331624
</td>
<td style="text-align:right;">
0.6061906
</td>
<td style="text-align:right;">
0.5020210
</td>
<td style="text-align:right;">
0.4326954
</td>
<td style="text-align:right;">
3.493500
</td>
<td style="text-align:right;">
1.930726
</td>
</tr>
</tbody>
</table></div>
</div>
<p>You can look at the <code>alpha.drop</code> section to see what the alpha would be if you dropped an item. If we add an item from the moral disgust scale, you can see that the alpha increases if you drop it.</p>
<div class="sourceCode" id="cb82"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">mixed_alpha</span> <span class="op">&lt;-</span> <span class="va">disgust</span> <span class="op">%&gt;%</span>
  <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">pathogen1</span><span class="op">:</span><span class="va">pathogen7</span>, <span class="va">moral1</span><span class="op">)</span> <span class="op">%&gt;%</span>
  <span class="fu">psych</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/psych/man/alpha.html">alpha</a></span><span class="op">(</span><span class="op">)</span>

<span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">mixed_alpha</span><span class="op">$</span><span class="va">alpha.drop</span>, <span class="va">raw_alpha</span>, <span class="va">std.alpha</span><span class="op">)</span></code></pre></div>
<div class="kable-table">
<div class="inline-table"><table class="table table-sm">
<thead><tr>
<th style="text-align:left;">
</th>
<th style="text-align:right;">
raw_alpha
</th>
<th style="text-align:right;">
std.alpha
</th>
</tr></thead>
<tbody>
<tr>
<td style="text-align:left;">
pathogen1
</td>
<td style="text-align:right;">
0.6776276
</td>
<td style="text-align:right;">
0.6873220
</td>
</tr>
<tr>
<td style="text-align:left;">
pathogen2
</td>
<td style="text-align:right;">
0.6770689
</td>
<td style="text-align:right;">
0.6903431
</td>
</tr>
<tr>
<td style="text-align:left;">
pathogen3
</td>
<td style="text-align:right;">
0.6693926
</td>
<td style="text-align:right;">
0.6799724
</td>
</tr>
<tr>
<td style="text-align:left;">
pathogen4
</td>
<td style="text-align:right;">
0.6787991
</td>
<td style="text-align:right;">
0.6911267
</td>
</tr>
<tr>
<td style="text-align:left;">
pathogen5
</td>
<td style="text-align:right;">
0.6704759
</td>
<td style="text-align:right;">
0.6776676
</td>
</tr>
<tr>
<td style="text-align:left;">
pathogen6
</td>
<td style="text-align:right;">
0.6860804
</td>
<td style="text-align:right;">
0.6980331
</td>
</tr>
<tr>
<td style="text-align:left;">
pathogen7
</td>
<td style="text-align:right;">
0.6823258
</td>
<td style="text-align:right;">
0.6950028
</td>
</tr>
<tr>
<td style="text-align:left;">
moral1
</td>
<td style="text-align:right;">
0.7379495
</td>
<td style="text-align:right;">
0.7441191
</td>
</tr>
</tbody>
</table></div>
</div>

</div>
<div id="css" class="section level2" number="4.24">
<h2>
<span class="header-section-number">4.24</span> CSS<a class="anchor" aria-label="anchor" href="#css"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>Cascading Style Sheet: A system for controlling the visual presentation of <a href="h.html#html">HTML</a> in web pages.</dfn></p>
<p><a href="r.html#r-markdown">R Markdown</a> scripts are often <a href="k.html#knit">knit</a> to HTML. Therefore, you can also include HTML (a way to semantically tag information) and CSS in your scripts.</p>
<p>Here is an example of some simple CSS (in the style tag) and HTML.</p>
<pre><code>&lt;style&gt;
  h3 { color: red; }
  .ferret { width: 200px; height: 150px; }
&lt;/style&gt;

&lt;h3&gt;Red Title&lt;/h3&gt;

&lt;img src="images/darwin.jpg" 
     title="The cutest ferret" 
     class="ferret"&gt;</code></pre>
<p><strong>Resources</strong></p>
<ul>
<li><a href="https://www.w3schools.com/css/" target="_blank">W3Schools Learn CSS</a></li>
<li><a href="https://debruine.github.io/tutorials/webpages.html#webpage-styles" target="_blank">Academic Webpages</a></li>
</ul>
</div>
<div id="csv" class="section level2" number="4.25">
<h2>
<span class="header-section-number">4.25</span> CSV<a class="anchor" aria-label="anchor" href="#csv"><i class="fas fa-link"></i></a>
</h2>
<p><dfn>Comma-separated variable: a file type for representing data where each variable is separated from the next by a comma.</dfn></p>

</div>
</div>
<script>

/* update total correct if #webex-total_correct exists */
update_total_correct = function() {
  console.log("webex: update total_correct");

  if (t = document.getElementById("webex-total_correct")) {
    var correct = document.getElementsByClassName("webex-correct").length;
    var solvemes = document.getElementsByClassName("webex-solveme").length;
    var radiogroups = document.getElementsByClassName("webex-radiogroup").length;
    var selects = document.getElementsByClassName("webex-select").length;
    
    t.innerHTML = correct + " of " + (solvemes + radiogroups + selects) + " correct";
  }
}

/* webex-solution button toggling function */
b_func = function() {
  console.log("webex: toggle hide");
  
  var cl = this.parentElement.classList;
  if (cl.contains('open')) {
    cl.remove("open");
  } else {
    cl.add("open");
  }
}

/* function for checking solveme answers */
solveme_func = function(e) {
  console.log("webex: check solveme");

  var real_answers = JSON.parse(this.dataset.answer);
  var my_answer = this.value;
  var cl = this.classList;
  if (cl.contains("ignorecase")) {
    my_answer = my_answer.toLowerCase();
  }
  if (cl.contains("nospaces")) {
    my_answer = my_answer.replace(/ /g, "")
  }

  if (my_answer == "") {
    cl.remove("webex-correct");
    cl.remove("webex-incorrect");
  } else if (real_answers.includes(my_answer)) {
    cl.add("webex-correct");
    cl.remove("webex-incorrect");
  } else {
    cl.add("webex-incorrect");
    cl.remove("webex-correct");
  }

  // match numeric answers within a specified tolerance
  if(this.dataset.tol > 0){
    var tol = JSON.parse(this.dataset.tol);
    var matches = real_answers.map(x => Math.abs(x - my_answer) < tol)
    if (matches.reduce((a, b) => a + b, 0) > 0) {
      cl.add("webex-correct");
    } else {
      cl.remove("webex-correct");
    }
  }

  // added regex bit
  if (cl.contains("regex")){
    answer_regex = RegExp(real_answers.join("|"))
    if (answer_regex.test(my_answer)) {
      cl.add("webex-correct");
    }
  }

  update_total_correct();
}

/* function for checking select answers */
select_func = function(e) {
  console.log("webex: check select");
  
  var cl = this.classList
  
  /* add style */
  cl.remove("webex-incorrect");
  cl.remove("webex-correct");
  if (this.value == "answer") {
    cl.add("webex-correct");
  } else if (this.value != "blank") {
    cl.add("webex-incorrect");
  }
  
  update_total_correct();
}

/* function for checking radiogroups answers */
radiogroups_func = function(e) {
  console.log("webex: check radiogroups");

  var checked_button = document.querySelector('input[name=' + this.id + ']:checked');
  var cl = checked_button.parentElement.classList;
  var labels = checked_button.parentElement.parentElement.children;
  
  /* get rid of styles */
  for (i = 0; i < labels.length; i++) {
    labels[i].classList.remove("webex-incorrect");
    labels[i].classList.remove("webex-correct");
  }
  
  /* add style */
  if (checked_button.value == "answer") {
    cl.add("webex-correct");
  } else {
    cl.add("webex-incorrect");
  }
  
  update_total_correct();
}

window.onload = function() {
  console.log("onload");
  /* set up solution buttons */
  var buttons = document.getElementsByTagName("button");

  for (var i = 0; i < buttons.length; i++) {
    if (buttons[i].parentElement.classList.contains('webex-solution')) {
      buttons[i].onclick = b_func;
    }
  }

  /* set up webex-solveme inputs */
  var solveme = document.getElementsByClassName("webex-solveme");

  for (var i = 0; i < solveme.length; i++) {
    /* make sure input boxes don't auto-anything */
    solveme[i].setAttribute("autocomplete","off");
    solveme[i].setAttribute("autocorrect", "off");
    solveme[i].setAttribute("autocapitalize", "off");
    solveme[i].setAttribute("spellcheck", "false");
    solveme[i].value = "";

    /* adjust answer for ignorecase or nospaces */
    var cl = solveme[i].classList;
    var real_answer = solveme[i].dataset.answer;
    if (cl.contains("ignorecase")) {
      real_answer = real_answer.toLowerCase();
    }
    if (cl.contains("nospaces")) {
      real_answer = real_answer.replace(/ /g, "");
    }
    solveme[i].dataset.answer = real_answer;

    /* attach checking function */
    solveme[i].onkeyup = solveme_func;
    solveme[i].onchange = solveme_func;
  }
  
  /* set up radiogroups */
  var radiogroups = document.getElementsByClassName("webex-radiogroup");
  for (var i = 0; i < radiogroups.length; i++) {
    radiogroups[i].onchange = radiogroups_func;
  }
  
  /* set up selects */
  var selects = document.getElementsByClassName("webex-select");
  for (var i = 0; i < selects.length; i++) {
    selects[i].onchange = select_func;
  }

  update_total_correct();
}

</script><script>
$( document ).ready(function() {
  var cite = ' ';
  var psyteachr = ' <a href="https://psyteachr.github.io/"><img src="images/logos/psyteachr_logo.png" style="height: 31px; color: white;" alt="psyTeachR: Reproducible Research" /></a>';
  var license = ' <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/" target="blank"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png"></a>';

  $("footer div.row div:eq(1) p").html(
    psyteachr + license + cite
  );
  
  $("#toc").appendTo($("#main-nav"));
});
</script><div class="chapter-nav">
<div class="prev"><a href="b.html"><span class="header-section-number">3</span> B</a></div>
<div class="next"><a href="d.html"><span class="header-section-number">5</span> D</a></div>
</div></main><div class="col-md-3 col-lg-2 d-none d-md-block sidebar sidebar-chapter">
    <nav id="toc" data-toggle="toc" aria-label="On this page"><h2>On this page</h2>
      <ul class="nav navbar-nav">
<li><a class="nav-link" href="#c"><span class="header-section-number">4</span> C</a></li>
<li><a class="nav-link" href="#cache"><span class="header-section-number">4.1</span> cache</a></li>
<li><a class="nav-link" href="#cache-web"><span class="header-section-number">4.2</span> cache (web)</a></li>
<li><a class="nav-link" href="#categorical"><span class="header-section-number">4.3</span> categorical</a></li>
<li><a class="nav-link" href="#character"><span class="header-section-number">4.4</span> character</a></li>
<li><a class="nav-link" href="#chunk"><span class="header-section-number">4.5</span> chunk</a></li>
<li><a class="nav-link" href="#ci"><span class="header-section-number">4.6</span> CI</a></li>
<li><a class="nav-link" href="#coding-scheme"><span class="header-section-number">4.7</span> coding scheme</a></li>
<li><a class="nav-link" href="#coercion"><span class="header-section-number">4.8</span> coercion</a></li>
<li><a class="nav-link" href="#comment"><span class="header-section-number">4.9</span> comment</a></li>
<li><a class="nav-link" href="#commit"><span class="header-section-number">4.10</span> commit</a></li>
<li><a class="nav-link" href="#compile"><span class="header-section-number">4.11</span> compile</a></li>
<li><a class="nav-link" href="#computational-reproducibility"><span class="header-section-number">4.12</span> computational reproducibility</a></li>
<li><a class="nav-link" href="#concatenate"><span class="header-section-number">4.13</span> concatenate</a></li>
<li><a class="nav-link" href="#confidence-interval"><span class="header-section-number">4.14</span> confidence interval</a></li>
<li><a class="nav-link" href="#conflict"><span class="header-section-number">4.15</span> conflict</a></li>
<li><a class="nav-link" href="#console"><span class="header-section-number">4.16</span> console</a></li>
<li><a class="nav-link" href="#container"><span class="header-section-number">4.17</span> container</a></li>
<li><a class="nav-link" href="#continuous"><span class="header-section-number">4.18</span> continuous</a></li>
<li><a class="nav-link" href="#correlation-matrix"><span class="header-section-number">4.19</span> correlation matrix</a></li>
<li><a class="nav-link" href="#correlation"><span class="header-section-number">4.20</span> correlation</a></li>
<li><a class="nav-link" href="#covariance-matrix"><span class="header-section-number">4.21</span> covariance matrix</a></li>
<li><a class="nav-link" href="#cran"><span class="header-section-number">4.22</span> CRAN</a></li>
<li><a class="nav-link" href="#cronbachs-alpha"><span class="header-section-number">4.23</span> Cronbach's alpha</a></li>
<li><a class="nav-link" href="#css"><span class="header-section-number">4.24</span> CSS</a></li>
<li><a class="nav-link" href="#csv"><span class="header-section-number">4.25</span> CSV</a></li>
</ul>

      <div class="book-extra">
        <ul class="list-unstyled">
<li><a id="book-source" href="https://github.com/psyteachr/glossary/blob/master/terms/c.Rmd">View source <i class="fab fa-github"></i></a></li>
          <li><a id="book-edit" href="https://github.com/psyteachr/glossary/edit/master/terms/c.Rmd">Edit this page <i class="fab fa-github"></i></a></li>
        </ul>
</div>
    </nav>
</div>

</div>
</div> <!-- .container -->

<footer class="bg-primary text-light mt-5"><div class="container"><div class="row">

  <div class="col-12 col-md-6 mt-3">
    <p>"<strong>Glossary</strong>" was written by psyTeachR Team. It was last built on 2022-02-10.</p>
  </div>

  <div class="col-12 col-md-6 mt-3">
    <p>This book was built by the <a class="text-light" href="https://bookdown.org">bookdown</a> R package.</p>
  </div>

</div></div>
</footer><!-- dynamically load mathjax for compatibility with self-contained --><script>
  (function () {
    var script = document.createElement("script");
    script.type = "text/javascript";
    var src = "true";
    if (src === "" || src === "true") src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML";
    if (location.protocol !== "file:")
      if (/^https?:/.test(src))
        src = src.replace(/^https?:/, '');
    script.src = src;
    document.getElementsByTagName("head")[0].appendChild(script);
  })();
</script><script type="text/x-mathjax-config">const popovers = document.querySelectorAll('a.footnote-ref[data-toggle="popover"]');
for (let popover of popovers) {
  const div = document.createElement('div');
  div.setAttribute('style', 'position: absolute; top: 0, left:0; width:0, height:0, overflow: hidden; visibility: hidden;');
  div.innerHTML = popover.getAttribute('data-content');

  var has_math = div.querySelector("span.math");
  if (has_math) {
    document.body.appendChild(div);
    MathJax.Hub.Queue(["Typeset", MathJax.Hub, div]);
    MathJax.Hub.Queue(function() {
      popover.setAttribute('data-content', div.innerHTML);
      document.body.removeChild(div);
    })
  }
}
</script>
</body>
</html>
